<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <p>p1</p>
    <b>b</b>
    <strong>strong</strong>
    <i>i</i>
    <del>del</del>
    <u>u</u>
    <li>li</li>
    <a href="#">a</a>
    <p>p2</p>
    <b>b</b>
    <strong>strong</strong>
    <i>i</i>
    <del>del</del>
    <u>u</u>
    <li>li</li>
    <a href="#">a</a>
    <br>
    <br>
    <textarea name="" id="" cols="30" rows="10"></textarea>
    <br>
    输入js代码，使用子代选择器，使所有p标签背景变色
    <input type="button" value="提交" onclick="toRed()">

</body>
<script>

    function toRed() {
        var myNodeList = document.body.querySelectorAll('p');
        for (var i = 0; i < myNodeList.length; ++i) {
            var item = myNodeList[i];
            item.innerHTML = "<mark>p</mark>";
        }
    }

</script>

</html>